summaryrefslogtreecommitdiffstats
path: root/resources/grub/patch/reproducible/[PATCH v3 1_3] mkstandalone: add argument --fixed-time to override mtime of files.eml
blob: 78d9f3d5232eb4e268b2ad971304fde6cf2311fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
Return-path: <grub-devel-bounces+info=gluglug.org.uk@gnu.org>
Envelope-to: info@gluglug.org.uk
Delivery-date: Fri, 04 Dec 2015 19:32:11 +0100
Received: from lists.gnu.org ([2001:4830:134:3::11])
	by web006.ispnoc.net with esmtps (TLSv1:AES256-SHA:256)
	(Exim 4.85)
	(envelope-from <grub-devel-bounces+info=gluglug.org.uk@gnu.org>)
	id 1a4v9P-00031J-Do
	for info@gluglug.org.uk; Fri, 04 Dec 2015 19:32:11 +0100
Received: from localhost ([::1]:42381 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <grub-devel-bounces+info=gluglug.org.uk@gnu.org>)
	id 1a4vA8-0001AP-Nv
	for info@gluglug.org.uk; Fri, 04 Dec 2015 13:32:56 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:47237)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lynxis@fe80.eu>) id 1a4v9t-00019X-Nm
	for grub-devel@gnu.org; Fri, 04 Dec 2015 13:32:42 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <lynxis@fe80.eu>) id 1a4v9s-0005RN-RM
	for grub-devel@gnu.org; Fri, 04 Dec 2015 13:32:41 -0500
Received: from mail.base45.de ([2001:67c:2050:310::a:2]:47554)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <lynxis@fe80.eu>) id 1a4v9s-0005R9-Kq
	for grub-devel@gnu.org; Fri, 04 Dec 2015 13:32:40 -0500
Received: from [2001:1a80:2259:2b1a:6042:6096:1de7:42c6] (helo=lazus.yip)
	by mail.base45.de with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128)
	(Exim 4.82) (envelope-from <lynxis@fe80.eu>)
	id 1a4v9n-0005Bc-ER; Fri, 04 Dec 2015 19:32:36 +0100
From: Alexander Couzens <lynxis@fe80.eu>
To: grub-devel@gnu.org
Subject: [PATCH v3 1/3] mkstandalone: add argument --fixed-time to override
	mtime of files
Date: Fri,  4 Dec 2015 19:32:20 +0100
Message-Id: <1449253942-29510-2-git-send-email-lynxis@fe80.eu>
X-Mailer: git-send-email 2.6.3
In-Reply-To: <1449253942-29510-1-git-send-email-lynxis@fe80.eu>
References: <1449253942-29510-1-git-send-email-lynxis@fe80.eu>
In-Reply-To: <1449245444-17579-1-git-send-email-lynxis@fe80.eu>
References: <1449245444-17579-1-git-send-email-lynxis@fe80.eu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:67c:2050:310::a:2
Cc: Alexander Couzens <lynxis@fe80.eu>
X-BeenThere: grub-devel@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: The development of GNU GRUB <grub-devel@gnu.org>
List-Id: The development of GNU GRUB <grub-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grub-devel>,
	<mailto:grub-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grub-devel>
List-Post: <mailto:grub-devel@gnu.org>
List-Help: <mailto:grub-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grub-devel>,
	<mailto:grub-devel-request@gnu.org?subject=subscribe>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: grub-devel-bounces+info=gluglug.org.uk@gnu.org
Sender: grub-devel-bounces+info=gluglug.org.uk@gnu.org

mkstandalone adds several files to an archive. Doing this it uses the
mtime to give these files a timestamp.
--fixed-time <TIME_EPOCH> overrides these timestamps with a given.

Replacing all timestamps with a specific one is required
to get reproducible builds. See source epoch specification of
reproducible-builds.org
---
 util/grub-mkstandalone.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c
index 4907d44..779c13c 100644
--- a/util/grub-mkstandalone.c
+++ b/util/grub-mkstandalone.c
@@ -30,6 +30,7 @@
 #pragma GCC diagnostic error "-Wmissing-prototypes"
 #pragma GCC diagnostic error "-Wmissing-declarations"
 
+static time_t fixed_time;
 static char *output_image;
 static char **files;
 static int nfiles;
@@ -48,6 +49,7 @@ static struct argp_option options[] = {
    0, N_("save output in FILE [required]"), 2},
   {"format", 'O', N_("FILE"), 0, 0, 2},
   {"compression", 'C', "xz|none|auto", OPTION_HIDDEN, 0, 2},
+  {"fixed-time", 0, N_("TIMEEPOCH"), 0, N_("Use a fixed timestamp to override mtime of all files. Time since epoch is used."), 2},
   {0, 0, 0, 0, 0, 0}
 };
 
@@ -72,6 +74,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
 static error_t
 argp_parser (int key, char *arg, struct argp_state *state)
 {
+  char *b;
   if (key == 'C')
     key = GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS;
 
@@ -80,6 +83,14 @@ argp_parser (int key, char *arg, struct argp_state *state)
 
   switch (key)
     {
+    case 't':
+      fixed_time = strtoll (arg, &b, 10);
+      if (*b !='\0') {
+        printf (_("invalid fixed time number: %s\n"), arg);
+        argp_usage (state);
+        exit (1);
+      }
+      break;
 
     case 'o':
       if (output_image)
@@ -192,7 +203,8 @@ add_tar_file (const char *from,
   if (grub_util_is_special_file (from))
     return;
 
-  mtime = grub_util_get_mtime (from);
+  /* use fixed_time if given for mtime */
+  mtime = fixed_time != -1 ? fixed_time : grub_util_get_mtime (from);
 
   optr = tcn = xmalloc (strlen (to) + 1);
   for (iptr = to; *iptr == '/'; iptr++);
@@ -293,6 +305,7 @@ main (int argc, char *argv[])
   const char *pkglibdir;
   int i;
 
+  fixed_time = -1;
   grub_util_host_init (&argc, &argv);
   grub_util_disable_fd_syncs ();
 
-- 
2.6.3


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel